//
//  WSChannelMoreController.m
//  CharonTVProject
//
//  Created by karong on 2023/8/1.
//

#import "WSChannelMoreController.h"
#import "WSChannelMoreRequest.h"
#import "WSChannelMoreCell.h"
#import "CTMediator+WSPlayerAction.h"

@interface WSChannelMoreController ()

@property (weak, nonatomic) IBOutlet UICollectionView *listView;

@end

@implementation WSChannelMoreController

- (void)viewDidLoad {
    [super viewDidLoad];
    WSChannelMoreRequest * request = [WSChannelMoreRequest new];
    request.charonTV_sort_type = self.charonTV_sort_type;
    self.request = request;
}

- (void)loadSuccessWithArray:(NSArray *)array isRefresh:(BOOL)isRefresh {
    [super loadSuccessWithArray:array isRefresh:isRefresh];
}

- (BOOL)disableAutoBeginRefresh {
    return YES;
}

#pragma mark CollectionViewDelegate
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    return 1;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return self.dataArray.count;
}

- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    WSChannelMoreCell * channelMoreCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"WSChannelMoreCell" forIndexPath:indexPath];
    [channelMoreCell setDataWithObject:self.dataArray[indexPath.row] index:indexPath.row + 1];
    return channelMoreCell;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    CGSize size = CGSizeZero;
    size.width = WSScreenWidth - 12 - 12;
    size.height = 158;
    return size;
}


- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    WSVideo * video = self.dataArray[indexPath.row];
    UIViewController * target = [[CTMediator sharedInstance]ct_showcharonTV_PlayerWithVideo:video];
    [self.navigationController pushViewController:target animated:YES];
}

@end
